<!DOCTYPE html>
<html lang="en">
<title>销课</title>
<#import "/layout/layout.html" as body/>
<@body.page>

<style>
    .chosen-container {
        width: 100% !important;
    }
</style>

<!--<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>课程管理</h2>
        <ol class="breadcrumb">
            <li><a href="to_order_list">订单管理</a></li>
            <li>私教课程</li>
            <li class="active"><strong>销课</strong></li>
        </ol>
    </div>
</div>-->
<input type="hidden" name="orderId" value="${orderId}" id="orderId"/>
<input type="hidden" name="orderId" value="${num}" id="course_num"/>
<input type="hidden" name="orderId" value="${msg}" id="request_msg"/>
<div class="wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title overflow">
                    <h5 class="pull-left">总课时：${num}</h5>
                    <span id="sssss_s">没有可销的课</span>
                </div>
                <div class="ibox-content">
                    <div id="div_courseAdd">
                        <#list course_sign_list as item>
                            <form method="get" class="form-horizontal" id="courseAdd_${item.courseNumber!}">
                                <div class="form-group margin-top"><label class="col-sm-12" id="keshi">课时：${item.courseNumber!}
                                    <span>
					                                   <#if item.isclose == '0'>
		                                                                                                             未销课     
		                                                </#if>
		                                                <#if item.isclose == '1'>
		                                                                                                             已销课     
		                                                </#if>
					                                </span>
                                </label></div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">上课时间</label>
                                    <div class="col-sm-10">
                                        <div class="input-group date">
                                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                            <input type="text" class="form-control" value="${(item.startTime?string('yyyy-MM-dd HH:mm'))!}" hhh="start_time_${item.courseNumber!}" fff="fff" id="startTime" name="startTime" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">关闭时间</label>
                                    <div class="col-sm-10">
                                        <div class="input-group date">
                                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                            <input type="text" class="form-control" value="${(item.closeTime?string('yyyy-MM-dd HH:mm'))!}" hhh="close_time_${item.courseNumber!}" fff="fff" id="closeTime" name="closeTime" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">上课门店</label>
                                    <div class="col-sm-10">
                                        <select data-placeholder="请输入门店" id="storeId" name="storeId" class="chosen-select" style="width:100%;" tabindex="2">
                                            <#list store_list as s>
                                                <option value="${s.id}"
                                                <#if item.storeId?? && item.storeId==s.id > selected="selected"</#if>
                                                >${s.storeName!}</option>
                                            </#list>
                                        </select>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group text-right">
                                    <#if item.isclose == '0'>
                                        <button type="button" class="btn btn-primary" onclick="cancel_course(${item.courseNumber!},${item.id!})" style="margin-right: 15px;" id="btn_save">确认销课</button>
                                    </#if>
                                    <input type="hidden" name="courseId" value="${item.courseId!}">
                                    <input type="hidden" name="id" value="${item.id!}">
                                    <input type="hidden" name="num" value="${item.courseNumber!}">
                                    <input type="hidden" name="orderId" value="${orderId!}">
                                    <input type="hidden" id="course_sign_count" value="${num!}">
                                </div>
                            </form>
                        </#list>
                    </div>
                    <form method="get" class="form-horizontal" id="courselist">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="${baseUrl}js/main.js"></script>

<script>
    $(document).ready(function () {
        $("input[fff*='fff']").datetimepicker({
            changeMonth: true,
            changeYear: true,
            timeFormat: 'hh:mm:00',
            stepHour: 2,
            stepMinute: 10,
            stepSecond: 10,
            dayNamesMin: ["七", "一", "二", "三", "四", "五", "六"],
            monthNamesShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"]
        });

        var course_sign_count = $("#course_sign_count").val();
        if (course_sign_count > 0) {
            $("#sssss_s").text(" ");
        }
    });


    function cancel_course(num, id) {
        var start_time = $("input[hhh=start_time_" + num + "]").val();
        if (start_time == '') {
            alert("请选择开始时间");
            $("input[hhh=start_time_" + num + "]").focus();
            return;
        }
        var close_time = $("input[hhh=close_time_" + num + "]").val();
        if (close_time == '') {
            alert("请选择关闭时间");
            $("input[hhh=close_time_" + num + "]").focus();
            return;
        }
        if (start_time > close_time) {
            alert("开始时间不能大于关闭时间");
            $("input[hhh=start_time_" + num + "]").focus();
            return;
        }
        var flag = confirm("确定销课吗?");
        if (flag) {
            var d = $("#courseAdd_" + num).serialize();
            var url = 'cancel_course';
            $.ajax({
                url: url,
                type: 'POST',
                data: d,
                async: false,
                success: function (returndata) {
                    if (returndata > 0) {
                        alert("销课成功!");
                        location.reload();

                    } else if (returndata == -1) {
                        alert("请按照顺序销课!");
                    }
                },
                error: function (returndata) {
                    alert(returndata);
                }
            });
        }
    }

    // Multi select//属性标签
    var config = {
        '.chosen-select': {},
        '.chosen-select-deselect': {
            allow_single_deselect: true
        },
        '.chosen-select-no-single': {
            disable_search_threshold: 10
        },
        '.chosen-select-no-results': {
            no_results_text: 'Oops, nothing found!'
        },
        '.chosen-select-width': {
            width: "95%"
        }
    }
    for (var selector in config) {
        $(selector).chosen(config[selector]);
    }
</script>

</@body.page>
</html>